<?php
namespace app\middleware;

use Tinywan\Jwt\JwtToken;
use Webman\MiddlewareInterface;
use Webman\Http\Response;
use Webman\Http\Request;

class Middleware implements MiddlewareInterface
{
    public function process(Request $request, callable $next) : Response
    {
        return $next($request);
        try {
            JwtToken::verify();

        }catch (\Exception $e){
            $msg =$e->getMessage();
            $data = [
                'code' => 40001,
                'message' => $msg,
                'data' => '',
            ];
            $options = JSON_UNESCAPED_UNICODE;
            $response = new Response(401, ['Content-Type' => 'application/json'], json_encode($data, $options));
            return $response;
        }
        return $next($request);
    }
    
}
